package wework

import (
	"encoding/json"
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
)

const CUSTOMER_SECRET = "0zDOfXgKw1eh2BSLfqPLou7B7gqRh46agwUIVUMLvkY"

func getMomentList(corpId string, secret string)  {
	token, err := GetAccessToken(corpId, secret)
	if err != nil {
		return
	}

	url := fmt.Sprintf("%s/externalcontact/get_moment_list?access_token=%s", WEWORK_HOST, token)


	resp, err := http.Get(url)
	if err != nil {
		log.Printf("GetAccessToken error. %v", err.Error())
		return
	}
	defer resp.Body.Close()
	log.Printf("status code is %d", resp.StatusCode)
	bytes, err := ioutil.ReadAll(resp.Body)
	var response GetTokenResponse
	json.Unmarshal(bytes, &response)
	fmt.Println(response.ToString())
	if SUCCESS == response.ErrCode {
		//setAccessTokenToRedis(corpId, corpSecret, response.AccessToken)
		//return response.AccessToken, nil
	}
}
